import {
  exportUrl,
  getLineCodeList,
  getProcessCodeList,
  getWorkCellCodeList,
  getWorkTeamCodeList,
  getWorkShiftCodeList,
  getWorkOrderCodeList,
  getWorkOrderNodeList,
} from "@/api/report/mesScanKeyparts";
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:operlog:export", //权限字段
  },
  // {
  //   name: "新增",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "add", //点击时返回的标识
  // },
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  // },
];
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit", //点击时返回的标识
  },
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail", //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete", //点击时返回的标识
  },
];
// 搜索条件配置
export const searchConfig = {
  data() {
    const _this = this;
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          barcode: {
            type: "input",
            label: $i18n.t("mesScanKeyParts.barCode"),
          },
          orderCode: {
            type: "input",
            label: $i18n.t("mesScanKeyParts.orderCode"),
          },
          // seriesCode: {
          //   type: "input",
          //   label: "系列编码",
          // },
          prodCode: {
            type: "input",
            label: $i18n.t("mesScanKeyParts.prodCode"),
          },
          prodName: {
            type: "input",
            label: $i18n.t("mesScanKeyParts.prodName"),
          },
          // materialCode: {
          //   type: "input",
          //   label: "物料编码",
          // },
          // materialName: {
          //   type: "input",
          //   label: "物料名称",
          // },
          lineCode: {
            type: "select",
            label: $i18n.t("common.lineName"),
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const params = {
                modelingCode: _this.$store.getters.factoryCode,
                level: 5,
              };
              const list = await getLineCodeList(params);
              return list.data.result;
            },
          },
          // processCode: {
          //   type: "select",
          //   label: "工序编码",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getProcessCodeList()
          //     return list.data.result
          //   },
          // },
          // workCellCode: {
          //   type: "select",
          //   label: "采集工位编码",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getWorkCellCodeList()
          //     return list.data.result
          //   },
          // },
          workTeamCode: {
            type: "select",
            label: $i18n.t("common.teamName"),
            prop: {
              value: "teamCode",
              text: "teamName",
            },
            options: async (data) => {
              const list = await getWorkTeamCodeList();
              return list.data.result;
            },
          },
          // workShiftCode: {
          //   type: "select",
          //   label: "采集班次编码",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getWorkShiftCodeList()
          //     return list.data.result
          //   },
          // },
          // userCode: {
          //   type: "input",
          //   label: $i18n.t("mesScanKeyParts.userCode"),
          // },
          userName: {
            type: "input",
            label: $i18n.t("mesScanKeyParts.userName"),
          },
          scanTime: {
            type: "datetimerange",
            label: $i18n.t("mesScanKeyParts.scanTime"),
            attrs: {
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              searchArrKey: ["scanTimeMin", "scanTimeMax"],
            },
          },
          // workOrderCode: {
          //   type: "select",
          //   label: "工单编码",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getWorkOrderCodeList()
          //     return list.data.result
          //   },
          // },
          // workOrderNode: {
          //   type: "select",
          //   label: "工单名称",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getWorkOrderNodeList()
          //     return list.data.result
          //   },
          // },
        },
      },
    };
  },
};
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    barcode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.barcode"),
      layout: 12,
      required: false,
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.orderCode"),
      layout: 12,
      required: false,
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.seriesCode"),
      layout: 12,
      required: false,
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.seriesName"),
      layout: 12,
      required: false,
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.prodCode"),
      layout: 12,
      required: false,
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.prodName"),
      layout: 12,
      required: false,
    },
    materialCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.materialCode"),
      layout: 12,
      required: false,
    },
    materialName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.materialName"),
      layout: 12,
      required: false,
    },
    keypartCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.keypartCode"),
      layout: 12,
      required: false,
    },
    status: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.status"),
      layout: 12,
      required: false,
    },
    lineCode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.lineCode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const params = {
          modelingCode: this.$store.getters.factoryCode,
          level: 5,
        };
        const list = await getLineCodeList(params);
        return list.data.result;
      },
    },
    lineName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.lineName"),
      layout: 12,
      required: false,
    },
    processCode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.processCode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getProcessCodeList();
        return list.data.result;
      },
    },
    processName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.processName"),
      layout: 12,
      required: false,
    },
    workCellCode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.workCellCode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getWorkCellCodeList();
        return list.data.result;
      },
    },
    workCellName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.workCellName"),
      layout: 12,
      required: false,
    },
    workTeamCode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.workTeamCode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getWorkTeamCodeList();
        return list.data.result;
      },
    },
    workTeamName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.workTeamName"),
      layout: 12,
      required: false,
    },
    workShiftCode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.workShiftCode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getWorkShiftCodeList();
        return list.data.result;
      },
    },
    workShiftName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.workShiftName"),
      layout: 12,
      required: false,
    },
    userCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.userCode"),
      layout: 12,
      required: false,
    },
    userName: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.userName"),
      layout: 12,
      required: false,
    },
    scanTime: {
      type: "datetime",
      label: $i18n.t("mesScanKeyParts.scanTime"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss",
      },
    },
    workOrderCode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.workOrderCode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getWorkOrderCodeList();
        return list.data.result;
      },
    },
    workOrderNode: {
      type: "select",
      label: $i18n.t("mesScanKeyParts.workOrderNode"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getWorkOrderNodeList();
        return list.data.result;
      },
    },
    factoryCode: {
      type: "input",
      label: $i18n.t("mesScanKeyParts.factoryCode"),
      layout: 12,
      required: false,
    },
    Remark: {
      type: "textarea",
      label: $i18n.t("mesScanKeyParts.Remark"),
      layout: 12,
      required: false,
    },
  },
};
